<?php
	require_once("mysql.php");

	if($_POST["params"])
	{		
		$json_str = stripslashes($_POST["params"]);
		$data_in = json_decode($json_str, true);
		$sql = new SQLdb("common_user", "");

		if($data_in)
		{
			switch($data_in["type_query"])
			{
				case "INSERT":
					$qa = $sql->query_array("SELECT `id` FROM presupuesto ORDER BY `id` DESC LIMIT 1");
					
					if($qa)
						$id = $qa[0]["id"] + 1;
					else
						$id = 0;

					$name = $data_in["data"][1];
					$email = $data_in["data"][2];
					$description = $data_in["data"][3];
					$style_desc = $data_in["data"][4];
					$colour_1 = $data_in["data"][5];
					$colour_2 = $data_in["data"][6];
					$colour_3 = $data_in["data"][7];
					$cont_forum = $data_in["data"][8];
					$cont_blog = $data_in["data"][9];
					$cont_users = $data_in["data"][10];
					$cont_chat = $data_in["data"][11];
					$cont_shop = $data_in["data"][12];
					$updates = $data_in["data"][13];
				
					$sql->query("INSERT INTO presupuesto (`id`, `name`, `email`, `description`, `style_desc`, `colour_1`, `colour_2`, `colour_3`, `cont_forum`, `cont_blog`, `cont_users`, `cont_chat`, `cont_shop`, `updates`) VALUES ('$id', '$name', '$email', '$description', '$style_desc', '$colour_1', '$colour_2', '$colour_3', '$cont_forum', '$cont_blog', '$cont_users', '$cont_chat', '$cont_shop', '$updates')");
					$res["error"] = mysql_error();

					echo json_encode($res);
					break;


			}
		}
	}

?>
